Poisson Events
Libraries
library(survival)
library(FRESA.CAD)
## Loading required package: Rcpp
## Loading required package: stringr
## Loading required package: miscTools
## Loading required package: Hmisc
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
## Loading required package: pROC
## Type 'citation("pROC")' for a citation.
##
## Attaching package: 'pROC'
## The following objects are masked from 'package:stats':
##
## cov, smooth, var
#source("~/GitHub/FRESA.CAD/R/RRPlot.R")
#source("~/GitHub/FRESA.CAD/R/PoissonEventRiskCalibration.R")
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
#pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
layout(matrix(1:1, nrow=1))
Parameters and
risk
censoredProb <- 0.000
timeSpan <- 10
timeInterval = 0.01
InitialPopulatoin <- 1000
ContBetaRate_1 <- 0.00005
BinBetaRate_1 <- 0.0005
BinBetaRate_2 <- 0.0002
BaselineHazard <- 0.00001
BinPrevalence1 <- 0.10
BinPrevalence2 <- 0.10
RContBetaRate_1 <- ContBetaRate_1
RBinBetaRate_1 <- BinBetaRate_1
RBinBetaRate_2 <- BinBetaRate_2
RBaselineHazard <- BaselineHazard
Simulate
#source("C:/Users/jtame/Documents/GitHub/RISKPLOTS/PlotRiskCategoriesAndTimetoEvent.R")
source("~/GitHub/RISKPLOTS/simulate_events.R")

RRplots Low
Prevalence
plotTimeInterval <- timeSpan*3 #Not calibrated.
hazard <- -log(1.0-simulatedDataFrame$pevent)
hboost <- plotTimeInterval/timeInterval
pvalue <- 1.0-exp(-hboost*hazard)
rdata <- cbind(simulatedDataFrame$status,pvalue)
summary(rdata[,2])
Min. 1st Qu. Median Mean 3rd Qu. Max. 0.04534 0.11878 0.14200 0.24371
0.17643 0.95448
table(simulatedDataFrame$status)
0 1 897 103
par(cex=0.75)
RRAnalysisCI <- RRPlot(rdata,atRate=c(0.90),
timetoEvent=simulatedDataFrame$time,
title="Simulation",
ysurvlim=c(0.00,1.0),
riskTimeInterval=plotTimeInterval)






RRAnalysisCI_LP <- RRAnalysisCI
par(op)
By Risk Categories
and Mean Time to Event
source("~/GitHub/RISKPLOTS/PlotRiskCategoriesAndTimetoEvent.R")


pander::pander(obsexp)
| Total |
103 |
84.1 |
124.9 |
107.0 |
0.962 |
0.786 |
1.17 |
0.735 |
| low |
51 |
38.0 |
67.1 |
49.5 |
1.031 |
0.768 |
1.36 |
0.776 |
| 90% |
52 |
38.8 |
68.2 |
57.8 |
0.899 |
0.671 |
1.18 |
0.510 |
pander::pander(timesdata)
| 1Q |
2.79 |
1.33 |
81.8 |
7.16 |
| Median |
4.94 |
3.68 |
100.5 |
9.66 |
| 3Q |
7.04 |
5.95 |
123.9 |
14.39 |
Risk
Calibration
op <- par(no.readonly = TRUE)
crdata <- cbind(simulatedDataFrame$status,pvalue,simulatedDataFrame$time)
#calprob <- CalibrationProbPoissonRisk(crdata,timeInterval=plotTimeInterval)
calprob <- CalibrationProbPoissonRisk(crdata)
( 8.214828 , 632.9083 , 0.9425186 , 103 , 106.8228 )
pander::pander(c(h0=calprob$h0,
Gain=calprob$hazardGain,
DeltaTime=calprob$timeInterval),
caption="Cox Calibration Parameters")
By Risk Categories
and Mean Time to Event after calibration
source("~/GitHub/RISKPLOTS/PlotRiskCategoriesAndTimetoEvent.R")


pander::pander(obsexp)
| Total |
103 |
84.1 |
124.9 |
107.0 |
0.962 |
0.786 |
1.17 |
0.735 |
| low |
51 |
38.0 |
67.1 |
49.5 |
1.031 |
0.768 |
1.36 |
0.776 |
| 90% |
52 |
38.8 |
68.2 |
57.8 |
0.899 |
0.671 |
1.18 |
0.510 |
pander::pander(timesdata)
| 1Q |
2.79 |
1.33 |
81.8 |
7.16 |
| Median |
4.94 |
3.68 |
100.5 |
9.66 |
| 3Q |
7.04 |
5.95 |
123.9 |
14.39 |
Second
Simulation
ContBetaRate_1 <- RContBetaRate_1*3
BinBetaRate_1 <- RBinBetaRate_1*2
BinBetaRate_2 <- RBinBetaRate_2*2
BaselineHazard <- RBaselineHazard*3
source("~/GitHub/RISKPLOTS/simulate_events.R")

Third Simulation
ContBetaRate_1 <- RContBetaRate_1*10
BinBetaRate_1 <- RBinBetaRate_1*5
BinBetaRate_2 <- RBinBetaRate_2*5
BaselineHazard <- RBaselineHazard*5
source("~/GitHub/RISKPLOTS/simulate_events.R")
